<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>总公司销售明细管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 
  <link rel="stylesheet" href="../../res/css/wholesale/font.css">
  <link rel="stylesheet" href="../../res/css/wholesale/xadmin.css">
  <link rel="stylesheet" href="../../res/layui/css/layui.css">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script type="text/javascript" src="../../res/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../../res/js/wholesale/xadmin.js"></script>
</head>
<body>
<div class="demoTable" style="margin-top: 10px;">
 
    <div class="x-body">
      <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
          <input type="text" name="sdId" id="sdId" placeholder="销售明细订单号" autocomplete="off" class="layui-input">
          <button class="layui-btn" data-type="reload" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
      </div>
<table class="layui-table" lay-data="{url:'../../listenSellDetail/selectAll.action', page:true, id:'idTest'}" lay-filter="demo">
  <thead>
    <tr>
      <th lay-data="{field:'sdId', align:'center'}">销售明细编号</th>
      <th lay-data="{field:'muName', align:'center'}">乐器名称</th>
      <th lay-data="{field:'mtName',align:'center'}">乐器类型</th>
      <th lay-data="{field:'muNumber', align:'center'}">乐器数量</th>
      <th lay-data="{field:'muPrice',align:'center'}">乐器价格</th>
      <th lay-data="{field:'subtotal', align:'center'}">小计</th>
      <th lay-data="{field:'openTime',align:'center', templet: '#operationTime'}">操作时间</th>
      <th lay-data="{field:'oper', align:'center'}">操作人</th>
    </tr>
  </thead>
</table>

 </div>
 </div>
<script src="../../res/js/wj/common.js" charset="utf-8"></script>

<script type="text/html" id="operationTime">
  {{ formatDate(d.openTime) }}  
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use('table', function(){
  var table = layui.table;
  var ids = getParameter("ids");
  
  //监听表格复选框选择
  table.on('checkbox(demo)', function(obj){
    console.log(obj)
  });
 
  
  /**
   * 从地址栏传值的代码
   * @param param
   * @returns
   */
  function getParameter(param){
  	var query = window.location.search;
  	var iLen = param.length;
  	var iStart = query.indexOf(param);
  	if (iStart == -1)
  		return "";
  	iStart += iLen + 1;
  	var iEnd = query.indexOf("&", iStart);
  	if (iEnd == -1)
  		return query.substring(iStart);
  	return query.substring(iStart, iEnd);
  }
  
  //表单重载
  var $ = layui.$, active = {
		    reload: function(){
		      var sdId = $('#sdId');
		      //执行重载    查询
		      table.reload('idTest', {
		        page: {
		          curr: 1 //重新从第 1 页开始
		        }
		        ,where: {
		        	sellId:getParameter("id"),
		        	sdId: sdId.val(),
		        	purchaseId:getParameter("ids")
		        }
		      });
		    }
		  };
  
  active['reload'] ? active['reload'].call(this) : '';
  
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});

</script>
</body>
</html>